Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 27, 2025

Adds spector test case for Azure Client Generator Core alternate-type spec. During implementation, discovered and fixed a critical bug in the TypeSpec-TS emitter that caused crashes when generating code for array types with undefined type metadata.

Bug Fix

modelUtils.ts: Fixed TypeError: Cannot read properties of undefined (reading 'includes') when processing array schemas where schema.items.type is undefined. Added null checks before accessing .includes() method.

// Before
} else if (schema.items.type.includes("|")) {

// After  
} else if (schema.items.type && schema.items.type.includes("|")) {

This occurred when processing TypeSpec types like numeric[] in the Geometry model's coordinates property.

Test Case Implementation

  • cadl-ranch-list.js: Added azure/client-generator-core/alternate-type to both azureRlcTsps and azureModularTsps
  • tspconfig.yaml: Created configuration files for RLC and Modular test directories
  • Test specs: Implemented azureAlternateType.spec.ts for both RLC and Modular with 4 test cases:
    • getModel / putModel: Tests Feature model with geometry, properties, and optional id
    • getProperty / putProperty: Tests ModelWithFeatureProperty wrapper

Generated client code successfully builds for both RLC and Modular flavors.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add spector case for Azure Alternate Type</issue_title>
<issue_description>typespec from https://github.com/Azure/typespec-azure/tree/main/packages/azure-http-specs/specs/azure/client-generator-core/alternate-type

  1. run rush update && rush build
  2. run rushx copy:typespec under folder packages/typespec.
  3. Add item into azureRlcTsps and azureModularTsps in file cadl-ranch-list.js.
    item:
  {
    outputPath: "azure/client-generator-core/alternate-type",
    inputPath: "azure/client-generator-core/alternate-type"
  }
  1. create tspconfig.yaml to azureIntegration/generated/azure/client-generator-core/alternate-type and azureModularIntegration/generated/azure/client-generator-core/alternate-type, the file configuration should refer to the cases in the same directory respectively.
  2. create azureAlternateType.spec.ts for azureIntegration and azureModularIntegration, then complete the case file according to the temp/specs/azure/client-generator-core/alternate-type/mockapi.ts
  3. Verify that all Integration case tests pass. If there are any issues, please fix them.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add spector case for Azure alternate type Add Azure Alternate Type spector case and fix array type generation bug Oct 27, 2025
Copilot AI requested a review from v-jiaodi October 27, 2025 08:26
Copilot finished work on behalf of v-jiaodi October 27, 2025 08:26
@v-jiaodi v-jiaodi added the Experiement Experiement PR/issue for AI label Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Experiement Experiement PR/issue for AI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add spector case for Azure Alternate Type

3 participants